<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body>
<?PHP
//echo phpinfo();
include("common/connect.php");
include("common/common.php");

echo "start<br>";
$b = 0;
$result = mysql_query( "select * from return_record" );
while( $result && $row = mysql_fetch_assoc( $result ))
{
	$tradeid = $row["trade_id"];
	echo "<br>-----".$tradeid."  ".$row["tb_id"]." ".$row["id"];
//	exit;
	
	$tradeid_begin = substr($tradeid, 0, 6);
	$tradeid_end = substr($tradeid, -4);
//	$itemid = $tradeid;//explode(';', $tradeid);
	//for($i=0; $i < count($itemid) - 1; $i++)
	{
		echo "<br>itemid ".$itemid[$i];
		$result2 = mysql_query("select * from order_handle_report where trade_id like '".$tradeid_begin."%".$tradeid_end."'");
		if( $result2 && mysql_num_rows($result2) > 0)
		{
			echo "<br>done  ";
//			$row2 = mysql_fetch_assoc( $result2 );
			$sql = "update return_record set sumcheck=1 where id=".$row["id"];
			//echo $sql;
			//continue;
			mysql_query( $sql );
			echo "  done2";
			if (mysql_affected_rows() == 0)
			{
				echo "<script>alert('处理过程中发生失败，请告诉程序员，出错代码：1');window.history.back();/script>";
				exit;
			}
			
	//		break;
		}
	}
}

echo "<br>end";
?>


</body>
</html>